<%@ page language="java" import="java.io.*, org.apache.log4j.*, com.erclab.internal.xpresso.security.User" %>
<%@ page isErrorPage="true" %>
<%  // -----------------------------------------------------------
    // This page Collects and stores errors generated in the 
    // application
    // -----------------------------------------------------------

    String exceptionOcurred = exception.toString();
    String exceptionMessage = exception.getMessage();

    if (exceptionMessage != null){
        exceptionMessage = exceptionMessage.replaceAll("'", "");
        exceptionMessage = exceptionMessage.replaceAll("\"", "");
    }

    String stackTrace;

    StringWriter sout = new StringWriter();
    PrintWriter pout = new PrintWriter(sout);
    exception.printStackTrace(pout);
    stackTrace = sout.toString();
    
    String ip = request.getRemoteAddr();

    String netId = (String)session.getAttribute("netId");

	Logger logger = Logger.getLogger("");
	logger.error("\n ******************* xpresso EXCEPTION ******************* " + 
				"\n The jsp error page caught an exception:\n"
						+ exceptionOcurred + "\n"
						+ exceptionMessage + "\n"
						+ stackTrace + "\n"
						+ "Current User: " +  ((User)session.getAttribute("user")).getNetId());
%>

<?xml version="1.0" encoding="utf-8"?>
<xpresso-error>
	<error-description>
		EXCEPTION OCURRED:
		<%= exceptionOcurred %>
		
		----------------------------- 
		ERROR STACK
		-----------------------------
		<%=stackTrace%> 
		-----------------------------
		END ERROR STACK
		-----------------------------
		  
	</error-description>
</xpresso-error>
